package com.ykw.parking.controller;

import com.ykw.parking.Utils.UploadImage;
import com.ykw.parking.pojo1.Imagepath;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;

@Controller
public class UploadImageController {
    @RequestMapping("/uploadImage")
    @ResponseBody
    public Imagepath test(@RequestParam(value = "file") MultipartFile multipartFile){
        String imagePath = UploadImage.upload(multipartFile);
        Imagepath test = new Imagepath();
        if(imagePath==null){
            return null;
        }else {
            HashMap<String,String> hashMap = new HashMap();
            hashMap.put("src",imagePath);
            test.setMap(hashMap);
            return test;
        }
    }
}
